package com.some;

import java.util.ArrayList;
import java.util.Scanner;

public class BianLiFeng {
    // 连接这些门店最少需要路数
    int roadNum = Integer.MAX_VALUE;
    // 路的总长度之和
    int roadDis = Integer.MAX_VALUE;

    public void doBetter(int[][] rooms) {
        // 思路：使用深度遍历。求得遍历完所有节点使用次数最少的步数，顺带求出联通所有的最短路径
        dfs(rooms, new int[]{0}, new boolean[rooms.length], 0, 0);
        System.out.print(roadNum + " " + roadDis);
    }

    public void dfs(int[][] rooms, int[] currents, boolean[] isVisit, int distance, int road) {
        // 每当访问完所有路径进行对比
        if (allVisit(isVisit)) {
            roadNum = Math.min(road, roadNum);
            roadDis = Math.min(distance, roadDis);
            return;
        }
        // 遇到访问过的门店则跳过
        ArrayList<Integer> list = new ArrayList<>();
        for (int current : currents) {
            if (!isVisit[current]) {
                list.add(current);
            }
        }
        // 下次需要访问的门店
        int[] ints = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            ints[i] = list.get(i);
        }

        for (int n = 0; n < ints.length; n++) {
            int anInt = ints[n];
            isVisit[anInt] = true;
            for (int i = 0; i < rooms[0].length; i++) {
                if (i != anInt && rooms[anInt][i] != -1 && !isVisit[i]) {
                    isVisit[i] = true;
                    dfs(rooms, ints, isVisit, distance + rooms[anInt][i], road + 1);
                    isVisit[i] = false;
                }
            }
        }

    }

    // 检查是否所有店铺都被访问到了
    public boolean allVisit(boolean[] isVisit) {
        for (boolean b : isVisit) {
            if (!b) {
                return false;
            }
        }
        return true;
    }


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] distances = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                distances[i][j] = scanner.nextInt();
            }
        }
        new BianLiFeng().doBetter(distances);
    }
}

